<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home></home>
  </div>
  <script src="./vue.js"></script>
  <script>
    const CommonTitle = {
      template: `
        <div>
          <h3>这是子组件</h3>  
          {{ a }}
          <br/>
          {{ b }}
          <br/>
          {{ c }}
          <br/>
          {{ d }}
          <br/>
          {{ e }}
        </div>
      `,
      // props验证写法
      props: {
        // 只要求数据类型
        a: Number,
        // 只要求数据类型 但是数据类型可以是多个
        b: [Number, String],
        // 既要求数据类型 还必须要传递值
        c: {
          type: Array,
          required: true
        },
        // 默认值
        d: {
          type: String,
          default: '默认值'
        },
        // 默认值特殊情况
        e: {
          type: Array,
          default: () => [1,2,3,4]
        }
      },
      mounted(){
        console.log(this);
      }
    }
    Vue.component('Home', {
      template: `
        <div>
          <h2>我是home</h2>  
          <hr/>
          <common-title :a="10" :b="[1,2,3]" :c="[2,3,4]"></common-title>
        </div>
      `,
      components: {
        CommonTitle
      }
    })
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>
</html>